<template>
	<view class="main">
		<navbar :config="config" backColor="#999999"></navbar>
		<view class="service-sys-moudle">
			<scroll-view scroll-x class="content" scroll-with-animation @scroll="scrollPointsBox">
				<view class="item" v-for="(item,index) in listData" :key="index" @click="goDetail(item)">
					<image class="cover" :src="item.cover" mode="aspectFill"></image>
					<view style="height: 1px;color: transparent;">{{item.randomNum}}</view>
					<view class="title">{{item.title}}</view>
					<view class="new-price">
						<text class="company">¥</text>
						<text class="num">{{formatPrice(item.min_sale_price,'int')}}.</text>
						<text class="float-num">{{formatPrice(item.min_sale_price,'float')}}</text>
					</view>
					<view class="old-price">¥ {{item.min_market_price}}</view>
				</view>
			</scroll-view>
		</view>
		<view class="split"></view>
		<view class="page-desc ql-editor-box">
			<u-parse :html="content"></u-parse>
		</view>
		<!-- <entrepreneurship-zone-tabbar :current="1"></entrepreneurship-zone-tabbar> -->
	</view>
</template>

<script>
	export default{
		data(){
			return {
				config: {
					back: true,
					title: '服务体系',
					color: 'black',
					backgroundColor: [1, "#fff"],
					statusBarFontColor: 'black'
				},
				listData: [],
				content: ''
			}
		},
		onLoad() {
			this.getList();
			this.getProtocol();
		},
		methods: {
			scrollPointsBox(){
				//获取0-10000随机数
				let randomNum = Math.floor(Math.random() * (10000 - 0)) + 0
				
				for(let i in this.listData){
					this.listData[i].randomNum = randomNum;
				}
			},
			/**
			 * @param {Object} type int或float
			 */
			formatPrice(price,type){
				let str = ''
				if(type=='int'){
					str = String(price).split('.')[0]
				}
				if(type=='float'){
					str = String(price).split('.').length <= 1?'00':(String(price).split('.')[1])
				}
				return str;
			},
			getList(){
				this.$http.get('/goodsareafeature/page',{
						page: 1,
						limit: 100,
						order_type: 1,
						order_mode: '',
						area_feature: 1
					})
				.then(res=>{
					if (res.code == 200) {
						let tempList = res.page.list;
						for(let i in tempList){
							tempList[i].randomNum = '';
						}
						this.listData = tempList;
					}
				})
			},
			goDetail(item){
				uni.navigateTo({
					url: `/pages/product/goods/goods?id=${item.goods_id}`
				})
			},
			getProtocol(){
				this.$http.get('/protocolConfig/info/service-agreement')
				.then(res => {
					if(res.code==200){
						this.content = res.data.content
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.main{
		.split{
			width: 100%;
			height: 8rpx;
			background: #f5f5f5;
		}
		.page-desc{
			padding: 30rpx;
		}
	}
</style>